package com._21cn.cms.template.utils.label;

import com._21cn.cms.yellow.entity.YellowPage;
import com._21cn.cms.yellow.service.YellowPageService;
import com._21cn.framework.flip.PageList;
import com._21cn.framework.utils.StringUtil;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class YellowPageLabel
{

    @Autowired(required=false)
    private YellowPageService yellowPageService;

    public PageList<YellowPage> getYellowPageList(String areaId, String cateId, String keyword, String pageNo, String pageSize) {
        Map params = new HashMap();
        if (StringUtil.isNumber(areaId)) {
            params.put("eqAreaId", Integer.valueOf(areaId));
        }
        if (StringUtil.isNumber(cateId)) {
            params.put("eqCateId", Integer.valueOf(cateId));
        }
        if (!StringUtil.isEmpty(keyword)) {
            params.put("likeName", keyword);
        }
        if (!StringUtil.isNumber(pageNo)) {
            pageNo = "1";
        }
        if (!StringUtil.isNumber(pageSize)) {
            pageSize = "10";
        }
        PageList list = this.yellowPageService.getList(params, Integer.valueOf(pageNo).intValue(), Integer.valueOf(pageSize).intValue());
        return list;
    }

    public YellowPage getYellowPage(String id) {
        YellowPage yellowPage = new YellowPage();
        if (StringUtil.isNumber(id)) {
            yellowPage = this.yellowPageService.getById(Integer.valueOf(id));
        }
        return yellowPage;
    }
}